//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
//
// (C) Copyright 2006 Marvell International Ltd.
// All Rights Reserved
//

#ifndef __SENSOR_H__
#define __SENSOR_H__

#include "xllp_camera.h"
#include "qci.h"
extern "C"
{
    #include "misc.h"
    #include "ippIP.h"
    #include "codecJP.h"
}
#include "Cs.h"
#include <Csmedia.h>

enum FrameSize
{
    QCIF,
    QQVGA,
    CIF,
    QVGA,
    VGA,
    SVGA,
    SXGA,
    UXGA,
    QXGA,
    FULL
};  

struct color_cfg_t
{
    unsigned int black_level;
    unsigned char* gama;
    float color_correct_coe[9];
};

struct camera_cfg_t
{
    PCS_DATARANGE_VIDEO format;
    int sensor_format;
    FrameSize sensor_size;
    format_t qci_format;
    color_cfg_t* color_cfg;
    IppiRawPixProcSpec_P3R* ippi_rpp_spec;
};

class Sensor
{
public:
    Sensor();
    qci_interface_t* get_qci_interface();
    XLLP_CI_MP_TIMING get_timing();
    virtual bool detect() = 0;
    virtual unsigned int get_formats(ULONG type, PCS_DATARANGE_VIDEO** formats) = 0;
    virtual void set_power_mode(bool is_on) = 0;
    virtual void set_frame_format(int format, FrameSize size) = 0;
    virtual void start_capture() = 0;
    virtual void stop_capture() = 0;
    virtual camera_cfg_t* get_camera_cfg(PCS_VIDEOINFOHEADER pCsVideoInfoHdr, ULONG mode) = 0;
    virtual void handle_frame_interrupt(PUCHAR buf,
                                        CS_BITMAPINFOHEADER* info_header,
                                        frame_t* frame) = 0;
    void init_camera_cfg(camera_cfg_t* cfg, BOOL is_still);
protected:
    qci_interface_t* qci_interface;
    XLLP_CI_MP_TIMING timing;
};

inline Sensor::Sensor()
{
    qci_interface = 0;
}

inline qci_interface_t* Sensor::get_qci_interface()
{
    return qci_interface;
}

inline XLLP_CI_MP_TIMING Sensor::get_timing()
{
    return timing;
}

#endif